﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Bidder_TrabidBacklist : System.Web.UI.Page, HZ.MBSM.BLL.TraDes
{
    // public string _strProjectId;  2007/08/22 马
    protected void Page_Load(object sender, EventArgs e)
    {
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            //_strProjectId = SysFun.ToTrim(Request.QueryString["ProjectId"]); 2007/08/22 马
            //  if (_strProjectId != "")
            // {
            showGridView();
            // }
        }
    }


    public void showGridView()
    {
        string strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "BackPlan_View";                                      //要查询的表明
        dbPage.Key = "BackPlanId";                                          //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "BackPlanId,HospitalName,PlanName,StartTime,BuildTime,case  when    BuyStatus='0' then '未采购' when  BuyStatus='1'then '已采购未提交' when    BuyStatus='2' then '已提交'   end BuyStatus";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 15;                                                    //没有显示记录条数   
        dbPage.OrderBy = "BuildTime,BackPlanId";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        DlAttorney.DataSource = dr;
        DlAttorney.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键
    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        string _strAccountId_PS = SysFun.ToTrim(_Account.AccountId);
        //此处在数据量增大后,要修改
        //string _strTemp = " projectid=" + _strProjectId + " and BuyStatus='2' and  BackPlanId in(select distinct BackPlanId from BackPlanGoods where AccountId_PS=" + _strAccountId_PS + ") and";
        // 2007/08/22 马
        string _strTemp = "  BuyStatus='2' and  BackPlanId in(select distinct BackPlanId from BackPlanGoods where AccountId_PS=" + _strAccountId_PS + ") and";

        //采购单名称
        string _strPlanName = txtPlanName.Text;
        if (_strPlanName != "")
        {
            _strTemp += "  PlanName like'%" + _strPlanName + "%' and";
        }

        //开始时间
        string _strStartTime = txtStartTime.Text.ToString();
        if (_strStartTime != "")
        {
            _strTemp += " StartTime>='" + _strStartTime + "' and";
        }

        //结束时间
        string _strEndTime = txtEndTime.Text.ToString();
        if (_strEndTime != "")
        {
            _strTemp += " StartTime <='" + _strEndTime + "' and";
        }
        if (_strTemp != "")
        {
            _strTemp = "  " + _strTemp.Substring(0, _strTemp.Length - 3);
        }
        return _strTemp;
    }


    #region TraDes 成员

    public string Name
    {
        get { return "退货单列表"; }
    }

    public string Describe
    {
        get { return ""; }
    }

    public string ParentName
    {
        get { return "配送管理"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
            return _AccountType;
        }
    }

    #endregion


}
